package com.example.zhu.Mapper;

import com.example.zhu.dto.Commodity;
import com.example.zhu.dto.MyPage;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CommodityMapper {
    //    查询所有
    @Select("select * from commodity order by id limit #{min}, #{max}")
    List<Commodity> getAllList(MyPage page);
    @Select("select count(id) from commodity")
    String getAllListCount();
    @Select("select * from commodity where name like #{name}")
    List<Commodity> getNameList( String name);
    @Select("select * from commodity where id=#{id}")
    Commodity selectById(Commodity commodity);
    @Update("update commodity set name=#{name} , amount=#{amount} ,status=#{status} WHERE id=#{id} ")
    void updataById(Commodity commodity);
    @Select("select * from commodity where name=#{name}")
    Commodity selectByName(Commodity commodity);
    @Insert("insert into commodity (name, amount, status) VALUES (#{name},#{amount},#{status})")
    void Insert(Commodity commodity);
    @Delete("delete from commodity where id=#{id}")
    void Delect(Commodity commodity);
    @Select("select * from commodity where status=1 ")
    List<Commodity> selectAll();
}
